package org.example;

import org.example.config.MyApplication;
import org.example.controller.LoginController;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/8/8
 * Time:15:04
 **/
public class App {
    public static void main(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("beans.xml");

        LoginController loginController = context.getBean(LoginController.class);
        loginController.sayHi();
//        MyApplication application = context.getBean(MyApplication.class);
//        System.out.println(application);
//

//        User user1 = (User) context.getBean("user1");
//        System.out.println(user1);
//
////        LoginController loginController = (LoginController) context.getBean(LoginController.class);
//
//        User user2 = context.getBean("user2",User.class);
//        System.out.println(user2);

//        LoginController loginController = (LoginController) context.getBean("loginController");
//        System.out.println(loginController);

//        URLController urlController =
//                (URLController) context.getBean("URLController");
//        System.out.println(urlController);

//        LoginController loginController = context.getBean(LoginController.class);

//        LoginController loginController2 = (LoginController) context.getBean("loginController");

//        System.out.println(loginController==loginController2);

        // 关闭容器
//        ((ClassPathXmlApplicationContext)context).close();


    }
}

